<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title th:text="${question.title}"></title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <script src="/js/jquery-3.4.1.min.js"></script>
    <script src="/js/bootstrap.min.js"></script>
    <script src="/js/moment.js"></script>
    <script src="/js/community.js"></script>
    <script src="/js/editormd.min.js"></script>
    <script src="/md/lib/marked.min.js"></script>
    <script src="/md/lib/prettify.min.js"></script>
    <link rel="stylesheet" href="/css/bootstrap.min.css">
    <link rel="stylesheet" href="/css/bootstrap-theme.min.css">
    <link rel="stylesheet" href="/css/editormd.preview.css">
    <link rel="stylesheet" href="/css/community.css">
    <link rel="stylesheet" href="/css/log.css">
</head>
<style>
    .d{
        margin:50px auto;
        width:80%;
    }
</style>
<body>

<div th:insert="~{menu :: menu}"></div>

<div class="container-fluid main profile d">
    <div class="row">
        <!-- 问题的显示 -->
        <div class="col-lg-9 col-md-12 col-sm-12 col-xs-12">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <h4 th:text="${question.title}"></h4>
                <em class="topic-info">
                    作者 <a class="aw-user-name" href="#" data-id="12368" th:text="${question.user.name}"></a>
                    | 发布于:<span th:text="${#dates.format(question.gmtCreate,'yyyy-MM-dd HH:mm')}"></span>				| 阅读数：<span th:text="${question.viewCount}"></span>
                </em>
                <hr>

                <div id="description-markdown-view" class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                    <textarea style="display:none;" th:text="${question.description}"></textarea>
                </div>
                <script type="text/javascript">
                    $(function() {
                        editormd.markdownToHTML("description-markdown-view", {});
                    });
                </script>

                <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12">

                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                    <span class="label label-info" th:each="tag : ${question.tag.split(',')} " style="margin-right: 10px">
                        <span class="glyphicon glyphicon-tags"></span>
                        <span class="label label-info" th:text="${tag}"></span>
                    </span>
                </div>

                <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12">

                <a class="topic-info" th:href="'/publish/'+${question.id}" th:if="${session.user != null && session.user.id == question.creator}">
                    <span class="glyphicon glyphicon-edit" aria-hidden="true">编辑</span>
                </a>
                <hr>
            </div>

            <!-- 回复的内容的展示 -->
            <h4>
                <span th:text="${question.commentCount}"></span> 个评论
            </h4>
            <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12" style="margin-top: 0">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" th:each="comment : ${comments}" style="margin-bottom: 15px; border-bottom: 1px solid #eee; padding-bottom: 5px">
                <div class="media">
                    <div class="media-left">
                        <a href="#">
                            <img class="media-object img-circle" th:src="${comment.user.avatarUrl}">
                        </a>
                    </div>
                    <div class="media-body" style="padding-top: 5px">
                        <h6>
                            <span class="media-heading" th:text="${comment.user.name}"></span>
                        </h6>
                        <div th:text="${comment.content}">
                        </div>
                        <div class="topic-info" style="margin-top: 10px">
                            <!--点赞-->
                            <span class="glyphicon glyphicon-thumbs-up icon"></span>
                            <!--取消点赞-->
                            <span class="glyphicon glyphicon-thumbs-down icon"></span>
                            <!--评论-->
                            <span class="icon" th:data-id="${comment.id}" onclick="collageChange(this)">
                                <sapn id="comment-icon" class="glyphicon glyphicon-comment"></sapn>
                                <span th:text="${comment.commentCount}"></span>
                            </span>

                            <span class="pull-right" th:text="${#dates.format(comment.gmtCreate,'yyyy-MM-dd')}"></span>
                        </div>
                    <!--二级评论-->
                        <div name="erji" class="col-lg-12 col-md-12 col-sm-12 col-xs-12 erjipinglun collapse" th:id="${'comment-'+comment.id}" style="
    padding: 10px;
    margin-top: 10px;
">
                            <div>
                                <input type="text" class="form-control" placeholder="评论一下..." th:id="${'replay-'+comment.id}"/>
                                <button class="btn btn-default pull-right" type="button" style="margin: 10px">取消</button>
                                <button class="btn btn-success pull-right" type="button" style="margin: 10px" onclick="comment(this)" th:data-id="${comment.id}">评论</button>
                            </div>
                        </div>

                    </div>

                </div>
            </div>

            <!-- 回复的框 -->
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <div th:if="${question != null}">
                    <div class="media" style="margin: 10px" id="comment_div">
                        <div>
                            <h4>下个神评就是你~~</h4>
                        </div>
                        <div class="media-body" style="padding-top: 5px">
                            <h6>
                                <span class="media-heading" th:text="${question.user.name}"></span>
                            </h6>
                        </div>
                        <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                            <textarea class="form-control comment" rows="3" id="comment"></textarea>
                            <input type="hidden" id="questionId" th:value="${question.id}"></input>
                            <button class="btn btn-success" style="float: right; margin-bottom: 10px;" onclick="post()">回复</button>
                        </div>
                    </div>
                </div>

            </div>

        </div>

        <div class="col-lg-3 col-md-12 col-sm-12 col-xs-12">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <h4>发起人</h4>
                <div th:if="${question != null}">
                    <div class="media">
                        <div class="media-left">
                            <a href="#">
                                <img class="media-object img-circle" th:src="${question.user.avatarUrl}">
                            </a>
                        </div>
                        <div class="media-body">
                            <h6 style="padding-top: 5px">
                                <span class="media-heading" th:text="${question.user.name}"></span>
                                <span class="glyphicon glyphicon-star-empty" aria-hidden="true" style="font-size: 12px; color: #999"></span>
                            </h6>
                        </div>
                    </div>
                </div>
            </div>
            <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
            <!--微信-->
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <h4>WeChat</h4>
                <img class="img-thumbnail" src="/images/wechat.jpg"/>
            </div>
            <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
            <!--相关问题-->
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <h4>相关问题</h4>
                <ul class="related">
                    <li th:each="relatedQuestion : ${relatedQuestions}" class="col-lg-12 col-md-12 col-sm-12 col-xs-12"
                        style="margin-bottom: 5px;">
                        <a class="a" th:text="${relatedQuestion.title}" th:href="'/question/'+${relatedQuestion.id}"></a>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</div>

<div th:insert="~{footer :: footer}"></div>
</body>
</html>